#!usr/bin/env python  
# -*- coding: utf-8 -*-
""" 
@author:Simon
@file: objdemo05.py 
@time: 2018/01/18 
"""
class MyObject(object):
     def __init__(self):
         self.x = 9
     def power(self):
         return self.x * self.x

obj = MyObject()

# print(hasattr(obj,'y'))
# setattr(obj,'y',21)
# print(hasattr(obj,'y'))
# print(getattr(obj,'y',404))

print(obj.power())

fnDemo = getattr(obj,'power')
print(fnDemo())

